import { formatHeader } from 'plugins/utils.js'

export function filterSuccess (state, payload) {
  let res = JSON.parse(payload)
  state.env.items = res.env
  state.parent.items = res.parent
  state.projectType.items = res.projectType
  state.status.items = res.status
  state.publish_type.items = res.publish_type
  state.owner.items = res.owner
  state.build_param.items = res.build_param
  state.pub_version.items = res.pub_version
  state.detection.items = res.detection
}

export function headerSuccess (state, payload) {
  let header = JSON.parse(payload)
  state.columns = formatHeader(header)
}

export function loadTableSuccess (state, payload) {
  state.tableData = payload.results
  state.serverPagination.rowsNumber = payload.count
  state.loading = false
}

export function closeSvg (state) {
  state.svgDialog = false
}

export function closeInfo (state) {
  state.infoDialog = false
}

export function showSvg (state, payload) {
  state.projectId = payload
  state.svgDialog = true
}

export function saltInfo (state, payload) {
  state.projectId = payload
  state.infoDialog = true
}
